using Behaving.Composites;

namespace Behaving
{
    public static class BE
    {
        public static THasName SetName<THasName>(this THasName behaviour, string name) where THasName : INamed
        {
            behaviour.Name = name;
            return behaviour;
        }

        public static TBehaviour SetName<TBehaviour>(string name, TBehaviour behaviour) where TBehaviour : Behaviour
        {
            behaviour.Name = name;
            return behaviour;
        }

        public static TBehaviour SetStartAction<TBehaviour>(this TBehaviour behaviour, System.Action action) where TBehaviour : Behaviour
        {
            behaviour.StartAction = action;
            return behaviour;
        }

        public static TBehaviour SetStopAction<TBehaviour>(this TBehaviour behaviour, System.Action action) where TBehaviour : Behaviour
        {
            behaviour.StopAction = action;
            return behaviour;
        }        

        public static TBehaviour AddChild<TBehaviour>(this TBehaviour behaviour, Behaviour child) where TBehaviour : Composite
        {
            behaviour.Children.Add(child);
            return behaviour;
        }
    }
}